<template>
  <div class="input-content">
    <svg-icon class="tool-complex" icon="tool-complex" />
    <div class="input unstyled">
      <input
        type="text"
        v-model="color"
        :placeholder="placeholder"
        @focus="setFocused"
        @blur="setBlur"
        @change="change"
      />
    </div>
  </div>
</template>

<script>
export default {
  props: {
    value: String,
    type: {
      type: String,
    },
    placeholder: {
      type: String,
      default: "",
    },
  },
  data() {
    return {
      color: this.value,
      focused: false,
    };
  },
  methods: {
    setFocused() {
      this.focused = true;
    },
    setBlur() {
      this.focused = false;
    },
    change(data) {
      this.$emit("input", data.target.value);
    },
  },
};
</script>

<style scoped lang="scss">
.input-content {
  width: 100%;
  box-sizing: border-box;
  border-radius: 2px;
  transition: all 0.28s;
  cursor: pointer;
  display: flex;
  justify-content: flex-start;
  align-items: center;

  .tool-complex {
    width: 24px;
    margin-right: 2px;
  }

  .unstyled {
    flex: 1;
    height: 100%;

    & input {
      background: none;
      border: 0px;
      outline: 0px;
      font-size: 14px;
      width: 100%;
      height: 24px;
      line-height: 24px;
      color: var(--color);

      &:hover {
        color: #409eff;
      }
    }
  }
}
</style>
